package tw.com.msig.xml;

import java.io.FileWriter;
import java.io.IOException;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;

public class Dom4j02App {

	public static void main(String[] args) {

		Document document = DocumentHelper.createDocument();
		Element rootElement = document.addElement("school");

		rootElement.addElement("student").addElement("name").addText("獅子")
				.addAttribute("id", "1");

		XMLWriter writer;
		try {
			writer = new XMLWriter(new FileWriter("C:\\temp\\sample02.xml"));
			writer.write(document);
			writer.close();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
}
